package com.github.postsanf.yinian.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;

import com.github.postsanf.yinian.R;
import com.github.postsanf.yinian.adapter.TimeMarksColorAdapter;
import com.umeng.analytics.MobclickAgent;

public class TimeMarksColorActivity extends AppCompatActivity {
    private ListView lv_color;
    private TimeMarksColorAdapter timeMarksColorAdapter;
    private String color = "#52d2ff,#f7d931,#f78a31,#ff525e,#46e0b3,#6436fd," +
            "#000000,#FFB6C1,#FFC0CB,#DC143C,#DB7093,#FF69B4,#FF1493,#C71585," +
            "#DA70D6,#D8BFD8,#DDA0DD,#EE82EE,#FF00FF,#8B008B,#800080,#BA55D3," +
            "#9400D3,#9932CC,#4B0082,#8A2BE2,#9370DB,#7B68EE,#6A5ACD,#483D8B," +
            "#0000FF,#0000CD,#191970,#00008B,#000080,#4169E1,#6495ED,#B0C4DE," +
            "#778899,#708090,#1E90FF,#4682B4,#87CEFA,#87CEEB,#00BFFF,#ADD8E6," +
            "#B0E0E6,#5F9EA0,#AFEEEE,#00FFFF,#00CED1,#2F4F4F,#008B8B,#008080," +
            "#48D1CC,#20B2AA,#40E0D0,#7FFFAA,#00FA9A,#00FF7F,#3CB371,#2E8B57," +
            "#90EE90,#98FB98,#8FBC8F,#32CD32,#00FF00,#228B22,#008000,#006400," +
            "#7FFF00,#7CFC00,#ADFF2F,#556B2F,#6B8E23,#FFFF00,#808000,#BDB76B," +
            "#FFFACD,#EEE8AA,#F0E68C,#FFD700,#DAA520,#F5DEB3,#FFE4B5,#FFA500," +
            "#FFEFD5,#FFEBCD,#FFDEAD,#D2B48C,#DEB887,#FFE4C4,#FF8C00,#CD853F," +
            "#FFDAB9,#F4A460,#D2691E,#8B4513,#A0522D,#FFA07A,#FF7F50,#FF4500," +
            "#E9967A,#FF6347,#FA8072,#F08080,#BC8F8F,#CD5C5C,#FF0000,#A52A2A," +
            "#B22222,#8B0000,#800000,#D3D3D3,#C0C0C0,#A9A9A9,#808080,#696969";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_time_marks_color);
        lv_color = ((ListView) findViewById(R.id.lv_color));
        String[] colors = color.split(",");
        timeMarksColorAdapter = new TimeMarksColorAdapter(TimeMarksColorActivity.this, colors);
        lv_color.setAdapter(timeMarksColorAdapter);
        closeActicity();
    }

    //接口回调
    private void closeActicity() {
        timeMarksColorAdapter.setOnColorListClickListener(new TimeMarksColorAdapter.OnColorListClickListener() {
            @Override
            public void onColorListClickListener(String colors) {
                Intent intent = new Intent();
                intent.putExtra("colors", colors);
                setResult(RESULT_OK, intent);
                finish();
            }
        });
    }

    // 友盟统计
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(this.getClass().getSimpleName());
        MobclickAgent.onResume(this);
    }

    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(this.getClass().getSimpleName());
        MobclickAgent.onPause(this);
    }
}
